package com.chat.entity.event;

import com.chat.entity.DataPackage;
import com.chat.net.socket.Channel;

/***
 *
 * Channel事件
 *
 */
public abstract class ChannelEvent implements Event {
    private static int count = 0;
    //事件id
    private int id;

    public ChannelEvent() {
        count++;
        id = count;
    }

    public void setId(int id) {
        this.id = id;
    }

    /**
     * 数据流事件
     * @param ctx 数据通道
     * @param source 数据源
     */
    public synchronized void onChannelEvent(Channel ctx, DataPackage source){
        onEvent();
    }

    @Override
    public void onEvent() {

    }

    public int getId() {
        return id;
    }

}
